package com.tjetc;

import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * @author gaoyongxiang
 * @version v1.0
 * @since 2025-10-17
 */
@SpringBootTest
public class TestRedis {

    @Resource
    private RedisTemplate<String, Object> redisTemplate;


    // Springboot操作redis的相关API
    @Test
    public void connection() {

        /*
            1. String: redisTemplate.opsForValue();
            2. List： redisTemplate.opsForList();
            3. Hash：redisTemplate.opsForHash();
            4. Set: redisTemplate.opsForSet();
            5. Zset: redisTemplate.opsForZSet();
         */
        System.out.println(redisTemplate);
    }

    @Test
    public void testString() {
        // 保存一个key-v
        redisTemplate.opsForValue().set("k2", "k2");
        String k2 = String.valueOf(redisTemplate.opsForValue().get("k2"));
        System.out.println(k2);
    }



}
